function HeGroupController(
    initialList,//路由中预加载数据的注入
    $scope,
    $rootScope,
    HeGroup,
    $uibModal,
    $state,
    $stateParams
) {
    var vm = this;
    vm.resultMsg;
    vm.scope = $rootScope.$new();

    initialList.$promise.then(function(response) {
        var rusersesultObj = response.page;
        vm.groups=rusersesultObj.content;
        vm.isLoaded = true;
        vm.queryParams = _.clone($stateParams)
        vm.totalItems = rusersesultObj.totalElements
        vm.totalPages = rusersesultObj.totalPages
    })

    vm.addOrdelRobot = function(group){
        $state.go('robotGroupDetail',{
            groupId:group.groupId,
            pageInfo: {
                pageSize: 10,
                pageNumber: 1
            }
        })
    }

    vm.createNewGroup = function(group) {
        if(group == null){
            $state.go('createGroup')
        }else{
            $state.go('createGroup' ,{
                groupId:group.groupId
            })
        }
    }

    vm.delete = function(group) {
        var modalInstance = $uibModal.open({
            templateUrl: 'delGroupComfimCtrl.html',
            controller: 'delGroupComfimCtrl'
        });

        // 模拟窗口关闭后回传调用
        modalInstance.result.then(function (selectedItem) {
            if(selectedItem == 'ok') {
                HeGroup.delete({
                    groupId : group.groupId
                }).$promise.then(function(response){
                    if(response.result == "err"){
                        vm.resultMsg = "删除失败，"+response.msg + " ！";
                        vm.scope.data = {
                            msg:vm.resultMsg
                        }
                        var tipsModel = $uibModal.open({
                            templateUrl: 'tipsModel.html',
                            controller: 'groupTipsCtrl',
                            scope:vm.scope
                        });
                    }else{
                        $state.reload($state.current);
                    }
                })
            }
        });
    }



    vm.reset = function(parameter) { vm.queryParams = {}; }

    vm.search = function() { $state.go($state.current, vm.queryParams) }

}

